﻿<cfscript>
/** 
* Standard Dictionary for Senate Frameworks
* 
* @hint "Standard Dictionary for Senate Frameworks" 
*/ 

component 
	displayname="public.service.util.senateDictionaryAdvice" 
	output=false 
	{
	
	/**
	* @hint "初始化对象"
	*/
	public public.service.util.senateDictionaryAdvice function init() output=false {
		return this;
	}

	/**
	* @hint "SYS 教材版次介绍"
	* 
	* @bookEdition "教材版本"
	* @divider "分隔符 默认为空格"
	*/
	public string function getBookEdition( required string bookEdition, string divider=" " ) output=false {

		var edition = listToArray(arguments.bookEdition, ",.");
		var fString = "";
		var pubYear = "";
		var pubTime = "";
		
		if ( arrayLen(edition) eq 2 ) {
			pubYear = edition[1];
			pubTime = edition[2];
		} 
		else if ( arrayLen(edition) and len(edition[1]) eq 4 ) {
			pubYear = edition[1];
			pubTime = "1";
		}
		else if ( arrayLen(edition) and len(edition[1]) eq 2 ) {
			
			pubYear = edition[1];
			
			pubYear = replace(pubYear, "T1", "自编讲义");
			pubYear = replace(pubYear, "T2", "影印资料");
			
			fString = pubYear;
			
		}
		else if ( arrayLen(edition) and len(edition[1]) eq 1 ) {
			pubTime = edition[1];
		}
		
		if ( pubYear neq "" and isNumeric(pubYear)) {
			fString = pubYear;
		}
		
		if ( pubTime neq "" ) {
		
			pubTime = replace(pubTime, "1", "一", "all");
			pubTime = replace(pubTime, "2", "二", "all");
			pubTime = replace(pubTime, "3", "三", "all");
			pubTime = replace(pubTime, "4", "四", "all");
			pubTime = replace(pubTime, "5", "五", "all");
			pubTime = replace(pubTime, "6", "六", "all");
			pubTime = replace(pubTime, "7", "七", "all");
			pubTime = replace(pubTime, "8", "八", "all");
			pubTime = replace(pubTime, "9", "九", "all");
		
			fString = fString & divider & "第" & pubTime & "版";		
		}
		
		return fString;
	}

	/**
	* @hint "SYS 教材条码格式化"
	* 
	* @ISBN "ISBN 编号"
	*/
	public string function getISBN( required string ISBN ) output=false {
		
		var fString = "";
		var isbnNumber = arguments.ISBN;
		
		if ( left(isbnNumber, 3) neq "SYS") {
			/* SYS 开头是系统默认书号 */
			
			if ( len(isbnNumber) eq 13 ) {
				fString = "ISBN " & mid(isbnNumber, 1, 3) & "-" & mid(isbnNumber, 4, 1) & "-" & mid(isbnNumber, 5, 3) & "-" & mid(isbnNumber, 8, 5) & "-" & mid(isbnNumber, 13, 1);
			}

			if ( len(isbnNumber) eq 10 ) {
				fString = "ISBN " & mid(isbnNumber, 1, 1) & "-" & mid(isbnNumber, 2, 2) & "-" & mid(isbnNumber, 4, 6) & "-" & mid(isbnNumber, 10, 1);
			}
			
		}
		
		return fString;
	}

	/**
	* @hint "SYS 楼栋建筑层数简介"
	* 
	* @buildingFloors "楼层字符串"
	*/
	public string function getBuildingFloorSummary( required string buildingFloors ) output=false {
		
		var upFloors = 0 + listFirst(arguments.buildingFloors);
		var downFloors = 0 + listLast(arguments.buildingFloors);

		var fString = (upFloors + downFloors) & "层建筑";
		
		if (downFloors gt 0) {
			fString = fString & ", 其中地下建筑" & downFloors & "层";
		}
		
		return fString;
	}
	
	/**
	* @hint "SYS 楼层代码翻译"
	* 
	* @floor "楼层字符串"
	*/
	public string function getFloorString( required string floor ) output=false {
		/*
			指房间所在的楼层，地上楼层直接用阿拉伯数字表示，地下楼层在阿拉伯数字前加“B”号，如“2”表示地上2 层，“B2”表示地下2 层
		*/
		
		var fString = "";
		var theFloor = arguments.floor;
		
		if (isNumeric(theFloor)) { theFloor = theFloor + 0; }
			
		if (len(theFloor) eq 2) {

			if (theFloor eq "10") { fString = replace(theFloor, "10", "十"); }
			else if (theFloor eq "20") { fString = replace(theFloor, "20", "廿"); }
			else if (theFloor eq "30") { fString = replace(theFloor, "30", "卅"); }
			else { fString = theFloor; }
			
			switch (left(fString, 1)) {
				
				case "1":
					fString = replace(fString, "1", "十");
					break;
				case "2":
					fString = replace(fString, "2", "廿");
					break;
				case "3":
					fString = replace(fString, "3", "卅"); 
					break;
				case "B":
					fString = replace(fString, "B", "地下"); 
					break;
				case "4":
				case "5":
				case "6":
				case "7":
				case "8":
				case "9":
					fString = left(fString, 1) & "十" & right(fString, 1); 
				
			}
		}
		else {
			fString = theFloor;
		}
		
		if (len(theFloor) lt 3) {
			fString = replace(fString, "0", "");
			fString = replace(fString, "1", "一", "all");
			fString = replace(fString, "2", "二", "all");
			fString = replace(fString, "3", "三", "all");
			fString = replace(fString, "4", "四", "all");
			fString = replace(fString, "5", "五", "all");
			fString = replace(fString, "6", "六", "all");
			fString = replace(fString, "7", "七", "all");
			fString = replace(fString, "8", "八", "all");
			fString = replace(fString, "9", "九", "all");
		}
		
		return fString & "楼";
	}

	/**
	* @hint "HB/HDXLFS-2002 获得学历方式代码 应用范围: 学生获得学历的方式"
	* 
	* @typeCode "字典代码"
	*/
	public string function getAcademicType( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "1": return "直接授予";
			case "2": return "参加学历文凭考试";
			case "9": return "其他";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS/TaskType-2012 教学任务类别代码 应用范围: 选排课中教学任务的类别"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTaskType( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "P": return "计划课程";
			case "C": return "全校通选课";
			case "T": return "体育项目";
			case "R": return "单开班";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS/StudyType-2012 修读方式代码 应用范围: 学生选课修读方式"
	* 
	* @typeCode "字典代码"
	*/
	public string function getStudyType( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "N": return "正常";
			case "R": return "重新学习";
			case "F": return "补修";
			case "S": return "双学位";
			case "A": return "辅修";
			case "E": return "跨年级";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS/TaskChangeReason-2013 教学任务临时调整原因 应用范围: 临时性调停课"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTaskChangeReason( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			
			case "00": return "节假日";
			
			case "10": return "公事出差";
			
			case "21": return "事假";
			case "22": return "病假";
			
			case "30": return "申请补课";
			case "31": return "补节假日课程";

			case "40": return "教学场地变更";
			
		}
		
		return "";
	}
	
	/**
	* @hint "SYS/TaskChangeType-2013 教学任务临时调整类别 应用范围: 临时性调停课"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTaskChangeType( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "10": return "停补课";
			case "11": return "停课";
			case "12": return "补课";
			case "20": return "调课";
			case "30": return "换教室";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS/ProgressStatus-2013 工作流处理状态 应用范围: 教务内部工作流"
	* 
	* @typeCode "字典代码"
	*/
	public string function getProgressStatus( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			
			case "S": return "成功";
			case "F": return "失败";
			
			case "W": return "等待审批";
			case "P": return "审批通过";
			case "B": return "驳回";
			case "D": return "已归档";
			case "C": return "撤销";
			
			case "1": return "正在编辑";
			case "2": return "已保存";
			case "3": return "已发布";
			
			case "U": return "未投票";
			case "V": return "投票中";
			case "Y": return "已投票";
			
			case "NO": return "未评教";
			case "C1": return "第一阶段评教完成";
			case "C2": return "第二阶段评教完成";
			case "CP": return "评教完成";
			

		}
		
		return "";
	}
	
	/**
	* @hint "SYS/TaskMarkStat-2012 成绩提交状态 应用范围: 教师成绩提交进度"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTaskMarkStat( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "0": return "未提交";
			case "1": return "录入中";
			case "2": return "已保存";
			case "3": return "已提交";
			case "4": return "已解锁";

			case "5": return "已过期";
			case "6": return "申请延期";
		}
		
		return "";
	}


	/**
	* @hint "GB/T 2261.1 个人基本信息分类与代码 第1部分：人的性别代码"
	* 
	* @typeCode "字典代码"
	*/
	public string function getGender( required string typeCode ) output=false {
		
		switch ( trim(arguments.typeCode) ) {
			case "0": return "未知";
			case "1": return "男";
			case "2": return "女";
			case "9": return "未说明";
		}
		
		return "";
		
	}

	
	/**
	* @hint "SYS/Boolean 是否标志"
	* 
	* @typeCode "字典代码"
	*/
	public string function getBoolean( required string typeCode ) output=false {
		
		if ( yesNoFormat(arguments.typeCode) ) {
			return "是";
		}
		else {
			return "否";
		}
	}

	/**
	* @hint "HB/XSDQZT-2006 学生当前状态代码 应用范围: 学生当前状态的类别"
	* 
	* @typeCode "字典代码"
	*/
	public string function getStudentCurrentStatus( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "01": return "在读";
			case "02": return "休学";
			case "03": return "退学";
			case "04": return "停学";
			case "05": return "复学";
			case "06": return "流失";
			case "07": return "毕业";
			case "08": return "结业";
			case "09": return "肄业";
			case "10": return "转学（转出）";
			case "11": return "死亡";
			case "12": return "保留入学资格";
			case "14": return "开除";
			case "15": return "下落不明";
			case "99": return "其他";
		}
		
		return "";
	}
	
	/**
	* @hint "HB/PYCC-2006 培养层次代码 应用范围: 学生的培养层次的分类"
	* 
	* @typeCode "字典代码"
	*/
	public string function getStudentLevel( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "1": return "博士";
			case "2": return "硕士";
			case "3": return "本科";
			case "4": return "专科";
			case "9": return "其他";
		}
		
		return "";
	}
	
	/**
	* @hint "HB/XQ-2002 学期代码"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTermEnrol( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "1": return "秋季招生";
			case "2": return "春季招生";
		}
		
		return "";
	}
	
	/**
	* @hint "HB/XQ-2002 学期代码"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTerm( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "1": return "秋季学期";
			case "2": return "春季学期";
			case "3": return "暑期小学期";
		}
		
		return "";
	}
	
	/**
	* @hint "HB/XQ-2002 学期代码"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTermName( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "1": return "秋";
			case "2": return "春";
			case "3": return "暑期";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS 评教模式"
	* 
	* @typeCode "字典代码"
	*/
	public string function getEvaluateModeName( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "M2": return "两段式评教";
			case "M3": return "三阶段评教";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS 计分模式"
	* 
	* @typeCode "字典代码"
	*/
	public string function getMarkModeName( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "0": return "百分制";
			case "2": return "两级制";
			case "4": return "五级制";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS 成绩备注"
	* 
	* @typeCode "字典代码"
	*/
	public string function getMarkNoteName( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "1": return "无";
			case "2": return "缺考";
			case "3": return "缓考";
			case "4": return "免修";
			case "9": return "违纪";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS 成绩提交轮次"
	* 
	* @typeCode "字典代码"
	*/
	public string function getMarkTurnName( required string typeCode ) output=false {
		
		switch (trim(arguments.typeCode)) {
			case "F": return "期末考试";
			case "R": return "补考";

			case "D": return "分散考试";
			case "M": return "期中考试";
			case "N": return "随堂考试";
		}
		
		return "";
	}
	
	/**
	* @hint "SYS 班级课表对应"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTaskTurnName( required string turn ) output=false {
		
		switch (trim(arguments.turn)) {
			case "1-1": return "1-2单";
			case "1-2": return "1-2";
			case "1-3": return "1-3";
			case "2-1": return "3-4单";
			case "2-2": return "3-4";
			case "3-1": return "5-6单";
			case "3-2": return "5-6";
			case "3-3": return "5-7";
			case "4-1": return "7-8单";
			case "4-2": return "7-8";
			case "5-1": return "10-11单";
			case "5-2": return "10-11";
		}
		
		return "";
	}
	
	
	/**
	* @hint "SYS 课程周次安排对应时间"
	* 
	* @typeCode "字典代码"
	*/
	public string function getTaskCourseTime( required string taskTime ) output=false {
		
		switch (trim(arguments.taskTime)) {
			case "1-1": return "0830-1000";
			case "1-2": return "0830-1000";
			case "1-3": return "0830-1200";
			case "2-1": return "1030-1200";
			case "2-2": return "1030-1200";
			case "3-1": return "1400-1530";
			case "3-2": return "1400-1530";
			case "3-3": return "1400-1720";
			case "4-1": return "1550-1720";
			case "4-2": return "1550-1720";
			case "5-1": return "1900-2030";
			case "5-2": return "1900-2030";
		}
		
		return "";
	}
}

</cfscript>